public class Hanoi {
    public static int countnum=0;
    public static void hanoi(int c,char posSrc,char mid,char posDest) {
        if(c==1){//递归中止的条件
            move(posSrc,posDest);
        }else{
        hanoi(c-1,posSrc,posDest,mid);
        move(posSrc,posDest);
        hanoi(c-1,mid,posSrc,posDest);
        }
    }
    public static void move(char posSrc,char posDest) {
        countnum++;
        System.out.println(posSrc+"->"+posDest);//注意表达形式
    }
    public static void main(String[] args) {
        hanoi(3,'A','B','C');
        System.out.println("移动的次数countnum:"+countnum);
    }
}
